const jsonwebtoken = require('jsonwebtoken');
const { SECRET, EXPRIRES } = require('../config/default.config');

/**
 * JWT
 * toker
 */

const JWT = {
  generateToken: (payload, exprires) => {
    return jsonwebtoken.sign(payload, SECRET, { expiresIn: exprires || EXPRIRES });
  },
  verifyToken: token => {
    try {
      return jsonwebtoken.verify(token, SECRET);
    } catch (error) {
      return false;
    }
  },
};

module.exports = JWT;
